﻿using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
using System.Data.Entity.Migrations;
using System.Linq;
using System.Runtime.Serialization;
using Se.Framework.Common.Data;

namespace Trust.Casas.Model.Entities
{
    [Table("BuildingType")]
    public class BuildingType : AuditableEntity, IGenericEntity
    {
        [Key]
        [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
        [DataMember]
        public int Id { get; set; }

        [DataMember]
        [StringLength(200)]
        public string Name { get; set; }

        [DataMember]
        [StringLength(200)]
        public string Description { get; set; }

        public object GenericId
        {
            get
            {
                return Id;
            }
        }

        public override string ToString()
        {
            return Name;
        }

        internal static void Initialize(DbSet<BuildingType> set)
        {
            set.AddOrUpdate(
                  p => p.Name,
                  new BuildingType { Name = "Casa" },
                  new BuildingType { Name = "Departamento" },
                  new BuildingType { Name = "PH" }
                );
        }
    }
}
